question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide more examples of use for interpolation and date-time formatting options

See original GitHub issue
  • I am on the latest ember-intl version
  • I have searched the issues of this repo and believe that this is not a duplicate

Environment

  • Ember Version: 3.7.2
  • Ember CLI Version: 3.7.1
  • Ember Intl Version: 3.5.0
  • Browser(s): Chrome
  • Node Version: 10.12.0

When migrating from ember-i18n and ember-moment, I can’t find any examples nor docs explaining how to properly replace the following snippet:

{{
      t "main.last.modified"
        date=(moment-format
        model.updatedAt "L HH:mm")
        user=model.modifiedBy
}}

with ember-intl’s one. The translation file has the following entry (I added date and time options later, they didn’t exist before):

main:
  last.modified: 'Last modified on {date, date, time} by {user}'

Taking a look at ember-intl-example app which is a little bit outdated didn’t bring any solution.

Having the above in place, I replace the old code in the template with the new one:

{{t "main.last.modified" date=currentShop.shop.country.updatedAt user=currentShop.shop.country.modifiedBy }}

and the date is displayed correctly but without time. What am I missing ? When should I use format-message helper, when just t, which options are available for date, times in templates and translation files ?

Thank you.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
belgoroscommented, Feb 1, 2019

OK, thanks a lot! I’ll close the issue

0reactions
jasonmitcommented, Feb 1, 2019

not sure if I need to keep hhmmss section in formats.js date section

You can remove it, it’s there as an example.

Read more comments on GitHub >

github_iconTop Results From Across the Web

string interpolation - format string output - Microsoft Learn
String interpolation provides a more readable, convenient syntax to format strings. It's easier to read than string composite formatting.
Read more >
The Comprehensive Guide to Custom DateTime String ...
When working with C#, we can convert a DateTime object to a string. If we don't specify any formatting options, the default DateTime......
Read more >
How to include a DateTime format as a constant inside string ...
I was upgrading code to use string interpolation, a feature introduced in C# 6, when I ran into a snag with DateTimes and...
Read more >
Python String Interpolation - Programiz
This new way of formatting strings is powerful and easy to use. It provides access to embedded Python expressions inside string constants.
Read more >
c# - Formatting dashes in string interpolation - Stack Overflow
The final version is more user friendly: var text = $"The time is {DateTime.Now:yyyy-MM-dd HH:mm:ss}";.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found