
I guess also "PRODUCER PROFILE" here should be replaced by the name of the enterprise that was just created...
If this issue is still open, I would like to work on it.
Please go ahead @amers185 ! Please ask in the #dev channel of our slack if you need assistance
Please have a look at our wiki page on i18n for an introduction on how we work on translations https://github.com/openfoodfoundation/openfoodnetwork/wiki/Internationalisation-%28i18n%29
fyi, this page will be tested in https://github.com/openfoodfoundation/openfoodnetwork/pull/3609
I dont think 3609 fixes this bug though.
@sigmundpetersen Thank you. I am familiar with the project because I was part of a group of college students who recently worked on the OFN documentation issue. I want to continue contributing in an individual capacity even though our group project ended. @luisramos0 Shall I continue working on the issue even if it will be tested in 3609?
hi @amers185
nice! thanks for your interest!
I just checked. you can fix this, it's independent of #3609
I leave you a hint ;-) https://github.com/openfoodfoundation/openfoodnetwork/blob/fb29a7c7c210e22863a6bbd4a1619da0d1c75b19/app/views/admin/enterprises/welcome.html.haml#L7
you probably want to do something like:
- if @enterprise.is_primary_producer
= t('.producer_profile')
- else
= t('.profile')
Ah thank you. So, on a high-level, this is not a missing key issue? Rather its more of not calling the right profile?
no, you have to make the code call the t function so that it looks up the translation key.
I feel rather dumb for asking this since I have only really inserted your code but this modification: "#{"producer " - if @enterprise.is_primary_producer? t('.producer_profile') - else t('.profile')}profile" in my IDE gives me an expected expression error at the dash before else and an expected herdoc end error? I have looked over different ways to try nested loops within tags for HAML but I am not quite share what I am doing wrong here. Further, how can I proceed to check for changes I make on the local host? As in, is there a go to strategy to navigate the local host given I do not know where this page is on the actual website? I cannot even access the french version on my local host. Again, my apologies for all these questions.
welcome to rails routing :-D
re second question: you need to look at the routes and then follow them to controllers and views.
look in admin.rb
you can load the old sample data locally with bundle exec rake ofn:dev:load_sample_data
the new sample data is loaded with ofn:data:sample_data
re the code, I'd have to do it myself to see, I am guessing the syntax a bit here but you could also try:
- profile_translation_key = @enterprise.is_primary_producer ? '.producer_profile' : '.profile'
= t(profile_translation_key)
I come back with more questions. Your advice was very helpful. I modified the syntax slightly and replaced one of the "=" signs with a ";". While that got rid of the original error, I still got this error:

I have a hunch that it has to do something with me being unable to load data because I get these errors when I run the commands you mention:

@luisramos0 Any help would be appreciated.
you can follow the error messages and run --tasks to see what tasks you have available
the tasks I get are:
rake ofn:dev:load_sample_data
rake ofn:sample_data
re the code, I recommend you read about ruby string interpolation and also about haml hyphen
Even if that one liner worked it wouldnt be accepted, it's way too much for a single line.
You can do this in a helper too.
What was the problem with my suggestion above?
@luisramos0 in the previous post you suggested ofn:data:sample_data while in the last post the tasks you list mention ofn:sample_data
Could this be a typo that prevented @amers185 from running the task?
I am editing my earlier message because I have made some progress. The fork I was working on was was behind master by a lot of commits. By rebasing and updating some bundles. I have managed to load the data, at least I think so because I get this when I run rake --tasks: 
I have also modified my code and made it modular, %strong = "#{"producer " if @enterprise.is_primary_producer ? t('.producer_profile') : t('.profile')}profile" Now when I go the welcome page, I get no errors and it looks like this:

Unfortunately, that still does not tell me if I fixed the original problem. Any guidance would be appreciated. @luisramos0 @sigmundpetersen
I also intend to go over a bunch of tutorials over the weekend and ask some questions in the dev channel. I appreciate the help and patience.
EDIT: aha, I see you made a major edit on your comment :-)
great, it works!
So the solution works? What is the next step?
that instructions in a single line is not acceptable imo, you need to at least split it into 2 lines as I shared above.
to test translations you need to edit application.yml and change it to french and see if translations from fr.yml are used.
you may need to add translation keys to both fr.yml and (for testing only) fr.yml
I have looked into string interpolation. According to several tutorials, this should work:
"#{@enterprise.is_primary_producer ? t('.producer_profile') : t('.profile')}" And it shows the following page:

In this case, tried changing the producer_profile value in en.yml file but the change does not get reflected in the view. So I am wondering what is happening there?
Unfortunately, I am unable to make the nested format with multi-line conditionals work and it gives the following page:

This is my code for it:

So, I am at quite a loss. Sorry for the deluge of messages. @luisramos0
Hey, you can do it!
string interpolation is for simple things, that code will never be acceptable with an if statement inside the interpolation.
you have to use view helpers or at least the hyphen on a separate line, before you call the t function.
I wouldnt even try to fix that if inside the interpolation
I had a look at it, my original suggestion is correct and works:
- profile_translation_key = @enterprise.is_primary_producer ? '.producer_profile' : '.profile'
= t(profile_translation_key)
All you need to do afterwords is to add the translation key in the right spot, because this is a lazy loading translation (with the dot). See here for more info. It's a good place to learn, I think most of this is generic rails i18n.
to look up lazy loading you need to see where the file is
you are in app/views/admin/enterprises/welcome.html.haml
that means your translation key namespace is admin.enterprises.welcome, so here, t('.profile') means t('admin.enterprises.welcome.profile') so, the translations key must go under:
https://github.com/openfoodfoundation/openfoodnetwork/blob/6cd07cd10795ce474dc48ed6735bad00cb13c5d2/config/locales/en.yml#L913


you dont need to test French, just make sure the en.yml key is being picked up, as I do in the screenshot above with custom string Profileee, in this case, the en.yml file should contain "Profile" and "Producer Profile". The French part is done after the PR is merged.
I hope this helps.
I was able to follow your instructions and it works now. Thank you so much for guiding me. I am sorry for not picking up your hints. I kept trying to make it work with string interpolation and then kept changing the wrong keys. I undid the changes I made earlier and made the correct changes. This was a very instructive experience. Thank you for being so patient. I guess a PR follows?