Code Monkey home page Code Monkey logo

i18n-postal-address's Introduction

javascript python go bash

👋 Hello there

  • 🔭 I’m currently working on the mobile app Litten and spreading the word on the Uyghurs
  • 🌱 I’m currently improving my knowledge in software engineering management, algorithms and data structures, design patterns, and object-oriented programming
  • 👯 I’m looking to collaborate on something that will have a positive (+) impact on the world
  • 🤔 I’m looking for help with every project I have public
  • 💬 Ask me about anything, really
  • 📫 How to reach me: [email protected]
  • 😄 Pronouns: he/his/him
  • ⚡ Fun fact: I love Star Wars ! Can you spot the reference ?

🎸 Music

Recently on Spotify
album cover No Good
by KALEO
on A/B [2016]

i18n-postal-address's People

Contributors

aravindanve avatar dependabot[bot] avatar ibrittanyhill avatar joaocarmo avatar lgtm-com[bot] avatar saiichihashimoto avatar tn819 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

i18n-postal-address's Issues

Hi i tried you package but somehow we cannot get the constructor running in node env.

Node script: using v12.9.1
`
const PostalAddress = require('i18n-postal-address')
//import PostalAddress from 'i18n-postal-address'

const myAddressPersonal = new PostalAddress()

myAddressPersonal
.setAddress1('Rua do Pastel, 19')
.setCity('Aveiro')
.setCountry('Brazil')
.setFirstName('John')
.setHonorific('Mr.')
.setLastName('Pestana')
.setPostalCode('2700-242')
.setSecondName('Lopes')
.setOutputFormat('array')
.setFormat({
country: 'NO',
type: 'personal',
})
`
Outputs:
const myAddressPersonal = new PostalAddress()
TypeError: PostalAddress is not a constructor

Any idea what I'm doing wrong here? The web based version seems to work really well..

Wrong default for Canada

Default for Sweden in address-formats.js is actually applied to Canada, resulting in error when canadian address specified without options.

address-formats.js, line 460
// Set Sweden's default to the personal format
addressFormats.CA.default = addressFormats.CA.personal

Question - Address Standardization

Thank you for the work on this library!

Is it possible to provide an address string and have it broken up into the respective parts? For example, given:

addressString = 'Rua do Pastel, 19, 2700-242 Aveiro, Pará, Brazil'

is it possible to get something like this returned:

  result: {
    addresss1: 'Rua do Pastel, 19',
    postalCode: '2700-242'
    city: 'Aveiro',
    province: 'Pará',
    country: 'Brazil'
   }

Where and international address string is broken into separate attributes?

Thank you!

Latin America: firstLastName, secondLastName and lastName

Expected Behavior

I am invoking the below formatting for a generic address that could be from many countries, and getting unexpected results with Latin America/Spain where I have not specified firstLastName or secondLastName.

In the code, I see we invoke on setLastName:

    this.setProperty('secondLastName', newValue)

which feels rather tricky.

I would expect if neither firstLastName or secondLastName is specified that we would assign no value to secondLastName.

Actual Behavior

setLastName also sets secondLastName

Steps to Reproduce

 postalAddress.setFormat({ country: 'ES' });

 postalAddress
   .setFirstName(firstName)
   .setLastName(lastName)
   .setCompanyName(company)
   .setAddress1(street)
   .setAddress2(addition)
   .setRegion(region) // region will be state in some locales, both don't seem to show at the same time so we pass to both
   .setState(region)
   .setPostalCode(zip)
   .setCity(place)
   .setCountry('Spain');

Your Environment

not related to code

Consider making `node-postal` an optional peer dependency.

Expected Behavior

i18n-postal-address can be installed without any warnings, even if node-postal is not installed. As per the README.md, the functionality is enables is experimental. If it can be helped, I would prefer not to have a native dependency.

Actual Behavior

For some package managers, adding a dependency without including its peer dependencies will give a warning. With some configurations (e.g. PNPM where strict-peer-dependencies is set to true), it'll error out.

Steps to Reproduce

  1. Run pnpm add i18n-postal-address on a package that does not have node-postal as a dependency.
  2. See warning.

Your Environment

[email protected]

I can file a PR for this, if you'd like.

addCommaAfter on custom format

Hi,
I'm trying to fetch a custom format from the server and apply it with transforms, something like this:

address.addFormat({
  country: addressData.countryCode,
  // this is my array of arrays from the server
  format: [["city", {"attribute": "postalCode", "transforms": ["addCommaAfter"]}]] 
  parser: "array",
  type: addressType
})

   // when I set the format I have also included:
.setFormat({
   country: addressData.countryCode,
   type: addressType,
   useTransforms: true
})

I seem unable to get commas to show up, perhaps this scenario isn't supported? or is this just the wrong approach?

US address missing comma after city

const myAddressPersonal = new PostalAddress();

myAddressPersonal
    .setAddress1('123 Nevermore Rd')
    .setCity('Austin')
    .setState('TX')
    .setPostalCode('78752')
    .setOutputFormat('array')
    .setFormat({
        country: 'US',
        type: 'personal',
        useTransforms: false,
    })
    .toString();

This returns

123 Nevermore Rd
Austin TX 78752

Instead of

123 Nevermore Rd
Austin, TX 78752

Are commas and other punctuation left out intentionally?

Allow access to Address Formats?

Hi. Great library, much appreciate the work that has gone into it.

I'm using the library in the "expected" mode, to render addresses, but I'm also attempting to use the configuration to render address forms, based on a country. So, for example, if someone is from Japan, then the address input form should match the format from address-formats.ts, here...

I had tried to do this by just setting all of the setters, like this:

    const address = new PostalAddress();
    address
      .setDo("do")
      .setDong("dong")
      .setGu("gu")
      .setSi("si")
      .setAddress1("address1")
      .setAddress2("address2")
      .setCity("city")
      .setRegion("region")
      .setProvince("province")
      .setPrefecture("prefecture")
      .setPostalCode("postalCode")
      .setState("state")
      .setRepublic("republic")
      .setFormat({ country, useTransforms: false });

    return address.toArray();

And then using the array format to determine which fields to display. Obviously, not what the library is designed for, but the address format information is very useful in this mode. However, because this code here...

public setAddress1(newValue: string): this {

clashes with

public setDong(newValue: string): this {

Because setAddress1 and setDong both get set at the same time, I can't effectively use this (admittedly hacky) method to get the address format, because it matters which set method I call first.

However, if the address formats were available from the PostalAddress object, e.g. .getFormat({ country: 'KR', type: 'personal' }), then that would be super useful to me.

Any chance? Should I raise a PR?

Thanks, Johnny

Allow adding custom format for countries not supported by default in library

Expected Behavior

Should format address for a country not supported by library with a newly added format

Actual Behavior

Formatting address with a new country (lets say GB) is not happening as the default list does not include GB

Steps to Reproduce

Add a custom format for "GB". Set address and invoke toArray() / toString(). It will use a default format and not the custom added format for GB.

const address = new PostalAddress().addFormat({ country: 'GB', format: [ ['address1'], ['city', 'postalCode'], ], type: 'personal', })

Module not found: Error: Package path . is not exported from package

Hi there!

I'm working on a project using Gatsby.js. Lately I upgraded dependencies to their latest version using node 18 from node 16. The upgrade went smoothly until I encountered this error during the build:

ModuleNotFoundError: Module not found: Error: Package path . is not exported from package /Users/.../node_modules/i18n-postal-address (see exports field in /Users/.../node_modules/i18n-postal-address/package.json)

As mentioned, it seems coming from the exports field

I can't figure it out why.

Steps to Reproduce

  1. Add i18n-postal-address as a project dependency yarn add i18-postal-address or npm install i18-postal-address
  2. Import and use i18n-postal-address as described https://github.com/joaocarmo/i18n-postal-address#with-a-bundler--nodejs
  3. Build the project yarn build or npm run build

Your Environment

macOS Ventura 13.2.1
VSCode 1.77.3
Yarn 1.22.19
Node.js v18.12.1
React 18.2.0
Gatsby 5.9.0

Types aren't a module

Looking into v0.4.1's typings in i18n-postal-address/dist/postal-address.d.ts, it declares a lot of modules, none of them 18n-postal-address.

image

Attempting to use the module in typescript fails, since the typings aren't a module.

image

Spread operator in dist causes bundling failure in Webpack version < 4

Expected Behavior

webpack built 67304625e5a5b0f1f395 in 36146ms 

Actual Behavior

ERROR in ./node_modules/i18n-postal-address/dist/postal-address.js
Module parse failed: Unexpected token (1:11913)
You may need an appropriate loader to handle this file type.

Specifications

VirtualBox: 5.2.12 r122591
Platform Host: Windows 10
Platform Guest: Ubuntu 16.04.4 LTS
Version: 0.0.4
Bundler: Webpack 3.11.0
Node version: 8.11.3

Other information

It looks like the cause of the error is the spread operator in the following line:

this.object = { ...objectInitialState }

Capitalized "UNITED STATES"

Looking through the formats, the only capitalized country is United States. This isn't a convention in the US (as far as I know) and, as a default for a lot of apps, it's strange to have constantly have "UNITED STATES", especially when other countries will not be like this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.