 
   ## Examples
 
-      iex> list_food_units()
+      iex> list_food_units("sv-FI")
       [%FoodUnit{}, ...]
 
   """
   def list_food_units(lang) do
     Repo.all(FoodUnit)
     |> Repo.preload([food_unit_trs: [:language]])
-    |> Enum.map(fn(%FoodUnit{food_unit_trs: trs} = unit) ->
-      with %FoodUnitTr{description: desc} <- Enum.find(trs, nil, fn(tr) -> tr.language.ietfTag == lang end) do
-        %{unit | description: desc}
-      else
-        nil -> %{unit | description: unit.thscode}
-      end
-    end)
+    |> Enum.map(&(localize_food_unit(&1, lang)))
   end
 
   @doc """

    FoodUnitTr
  }

  @doc """
  Returns the list of food_units. The results will
  be localized according to the lang parameter, which should


  ## Examples

      iex> get_food_unit!(123, "fi-FI")
      %FoodUnit{}

      iex> get_food_unit!(456, "sv-FI")
      ** (Ecto.NoResultsError)

  """
  def get_food_unit!(id, lang) do
    Repo.get!(FoodUnit, id)
    |> Repo.preload([food_unit_trs: [:language]])
    |> localize_food_unit(lang)
  end

  @doc """
  Creates a food_unit.
