Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added tests for i18n #79

Merged
merged 2 commits into from
Mar 28, 2022
Merged

added tests for i18n #79

merged 2 commits into from
Mar 28, 2022

Conversation

maliyildiz1
Copy link
Member

No description provided.

@maliyildiz1 maliyildiz1 self-assigned this Mar 19, 2022
@maliyildiz1 maliyildiz1 linked an issue Mar 19, 2022 that may be closed by this pull request
Copy link
Member

@jankapunkt jankapunkt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const isPlainObj = obj => Object.prototype.toString.call(obj) === '[object Object]'
const equal = (a, b) => {
  const keysa = Object.keys(a).sort()
  const keysb = Object.keys(b).sort()
  
  if (keysa.length !== keysb.length) {
    return false
  }
  
  if (keysa.toString() !== keysb.toString()) {
    return false
  }
  
  // both keys are equal
  return keysa.every(key => {
    const valuea = a[key]
    const valueb = b[key]
    const typea = typeof valuea
    const typeb = typeof valueb
    
    if (typea !== typeb) { return false }
    if (typea === 'string') { return true }
    if (!isPlainObj(valuea) || !isPlainObj(valueb)) { return false }
    
    return equal(valuea, valueb)
  })
}

@jankapunkt jankapunkt merged commit 4d98dd0 into main Mar 28, 2022
@jankapunkt jankapunkt deleted the i18n-test branch March 28, 2022 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

i18n tests
2 participants